/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gizelle.myApp.services.crud.impl;

import com.gizelle.myApp.domain.Membership;
import com.gizelle.myApp.repository.nosql.GenericDAO;
import com.gizelle.myApp.services.crud.MembershipCrudService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Gizelle
 */
@Service("MembershipCrudService")
@Transactional
public class MembershipCrudServiceImpl implements MembershipCrudService {

    @Autowired
    private GenericDAO<Membership> dao;

    public final void setDao(final GenericDAO< Membership> daoToSet) {
        this.dao = daoToSet;
        this.dao.setClazz(Membership.class);
    }

    public MembershipCrudServiceImpl() {
    }

    @Override
    public Membership findById(Long id) {
       setDao(dao);
        return dao.findById(id);
    }

    @Override
    public List<Membership> findAll() {
        setDao(dao);
        return dao.findAll();
    }

    @Override
    public void persist(Membership entity) {
         setDao(dao);
        dao.persist(entity);
    }

    @Override
    public void merge(Membership entity) {
         setDao(dao);
        dao.merge(entity);
    }

    @Override
    public void remove(Membership entity) {
        setDao(dao);
        dao.remove(entity);
    }

    @Override
    public void removeById(Long entityId) {
      setDao(dao);
        Membership ms = dao.findById(entityId);
        dao.remove(ms);
    }

    @Override
    public List<Membership> findInRange(int firstResult, int maxResults) {
          setDao(dao);
        return dao.findInRange(firstResult, maxResults);
    }

    @Override
    public long count() {
          setDao(dao);
        return dao.count();
    }

    @Override
    public Membership getByPropertyName(String name, String value) {
          setDao(dao);
        return dao.getByPropertyName(name, value);
    }

    @Override
    public List<Membership> getEntitiesByProperName(String name, String value) {
         setDao(dao);
        return dao.getEntitiesByPropertyName(name, value);
    }
}
